<template>
    <div class="newsinfo-container">
        <!--大标题-->
        <h1 class="title">新闻详情</h1>
        <!--子标题-->
        <p class="sub-title">
            <span>发表时间:2020/1/8</span>
            <span>点击次数:0</span>
        </p>
        <hr>
        <!--内容区域-->
        <div class="content" v-html="item.content" v-for="(item,key) in dataList" @click="getData()" :key="key" v-if="item.id == id">
        </div>
        <!--评论子组件-->
        <comment-box></comment-box>
    </div>
</template>
<script>
    import {Toast} from "mint-ui"
    import comment from '../subcomponents/comment.vue'  //导入评论组件
    export default {
        data(){
            return {
                id:this.$route.params.id , //将地址中传递过来的id值挂在在data上,方便以后调用
                dataList:null
            }
        },
        
        created(){
            this.getData()
        },
        methods:{
            getData(){
                this.$http.get("/src/data.json").then(result =>{
                    if(result.ok){
                        this.dataList = result.body
                    }else{
                        Toast("获取数据失败!")
                    }
                })
            }
        },
        components:{
            "comment-box":comment
        }
    }
</script>

<style lang="scss">
    .app-container{
        padding: 0 4px;
        .title{
            font-size: 16px;
            text-align: center;

        }
        .sub-title{
            font-size: 14px;
            color: #26A2FF;
            display: flex;
            justify-content: space-between;
            margin-left: 10px;
            margin-right: 10px;
        }
        .content{
            font-size: 30px;
            line-height: 50px;
            color: red;
            position: relative;
            .img2{
                height: 350px;
                width: 400px;
                position: absolute;
                z-index: -1;
                left: 0;
                top: 0;
            }
        }
    }
</style>